fdt: Fix regression in fdt_pack_reg()
authorHans de Goede <[email protected]>
Fri, 28 Nov 2014 13:23:51 +0000 (14:23 +0100)
committerSimon Glass <[email protected]>
Mon, 1 Dec 2014 15:23:32 +0000 (08:23 -0700)
After commit 933cdbb479: "fdt: Try to use fdt_address_cells()/fdt_size_cells()"
I noticed that allwinner boards would no longer boot.

Switching to fdt_address_cells / fdt_size_cells changes the result from
bytes to 32 bit words, so when we increment pointers into the blob, we must
do so by 32 bit words now.

This commit makes allwinner boards boot again.

Signed-off-by: Hans de Goede <[email protected]>
Tested-by: Masahiro Yamada <[email protected]>
Acked-by: Simon Glass <[email protected]>
Tested-by: Stefan Roese <[email protected]>
Tested-by: Vince Hsu <[email protected]>
common/fdt_support.c

index ea42c63eaafd74300374dd5734726f6a64aaf8e3..6254e342fd26aa3ad78f3d2160f37c6191ff4503 100644 (file)
@@ -370,22 +370,22 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,
                        int n)
 {
        int i;
-       int address_len = fdt_address_cells(fdt, 0);
-       int size_len = fdt_size_cells(fdt, 0);
+       int address_cells = fdt_address_cells(fdt, 0);
+       int size_cells = fdt_size_cells(fdt, 0);
        char *p = buf;
 
        for (i = 0; i < n; i++) {
-               if (address_len == 2)
+               if (address_cells == 2)
                        *(fdt64_t *)p = cpu_to_fdt64(address[i]);
                else
                        *(fdt32_t *)p = cpu_to_fdt32(address[i]);
-               p += address_len;
+               p += 4 * address_cells;
 
-               if (size_len == 2)
+               if (size_cells == 2)
                        *(fdt64_t *)p = cpu_to_fdt64(size[i]);
                else
                        *(fdt32_t *)p = cpu_to_fdt32(size[i]);
-               p += size_len;
+               p += 4 * size_cells;
        }
 
        return p - (char *)buf;